package com.motus.pm.daoImpl;


import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.motus.pm.dao.MeetingInfoDao;
import com.motus.pm.vo.PmMeetingInfo;

@Repository
public class MeetingInfoDaoImpl extends BaseDaoImpl<PmMeetingInfo>implements MeetingInfoDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<PmMeetingInfo> getMeetingInfosByDeptId(int deptId) {
		Session session=sessionFactory.getCurrentSession();
		String sql="select * from pm_meeting_info where mid in"+
					"(select mid from pm_dept_task where dept_id=?)";
		Query query=session.createSQLQuery(sql).addEntity(PmMeetingInfo.class);
		query.setInteger(0, deptId);
		return query.list();
	}

	@Override
	public List<PmMeetingInfo> getMeetingInfoListByType(int type) {
		// TODO Auto-generated method stub
		Session session = sessionFactory.getCurrentSession();
		String hql = "from PmMeetingInfo where meetingType = ?";
		Query query = session.createQuery(hql);
		query.setInteger(0, type);
		return query.list();
	}
	
}
